<template>
  <div class="divBox">
    <el-card class="box-card">
      <el-form inline size="small" @submit.native.prevent>
        <el-form-item label="村级活动：">
          <el-select v-model="listPram.activityId" placeholder="村级活动" clearable style="width: 100%">
            <el-option
              v-for="(item,index) in activityList.list"
              :key="index"
              :label="item.title"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="用户关键词：">
          <el-input v-model="listPram.keyword" placeholder="请输入姓名或手机号" clearable class="selWidth"/>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-search" size="mini" type="primary" @click="handleSearch">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table :data="listData.list"  v-loading="loading" size="mini" :header-cell-style=" {fontWeight:'bold',background:'#f8f8f9',color: '#515a6e',height:'40px'}" border>
        <el-table-column
          prop="id"
          label="ID"
          width="50"
        />
        <el-table-column label="活动名称" prop="activityText" min-width="120"/>
        <!-- <el-table-column
          label="头像" min-width="80">
          <template slot-scope="scope">
            <div class="demo-image__preview">
              <el-image
                style="width: 36px!important; height: 36px!important;"
                :src="scope.row.avatar"
                :preview-src-list="[scope.row.avatar]"
              />
            </div>
          </template>
        </el-table-column> -->
        <el-table-column label="姓名" prop="name" min-width="100"/>
        <el-table-column label="手机号" prop="phone" min-width="100"/>
        <el-table-column label="身份证号" prop="idCard" min-width="100"/>
        <el-table-column label="报名状态" prop="statusText" min-width="80">
          <template slot-scope="scope">
            <span :style="'color:'+handleGetLightColor(scope.row.status)">{{scope.row.statusText}}</span>
          </template>
        </el-table-column>
        <el-table-column label="报名时间" prop="createTime" min-width="80"/>
        <el-table-column label="现场图片审核状态" prop="auditStatusText" min-width="80">
          <template slot-scope="scope">
            <span :style="'color:'+handleGetLightColor(scope.row.auditStatus)" v-if="scope.row.status === 1 && scope.row.filesArr.length > 0">{{scope.row.auditStatusText}}</span>
            <span v-else>-</span>
          </template>
        </el-table-column>
<!--        <el-table-column label="排序" prop="sort" min-width="120" />-->
        <el-table-column label="操作" min-width="130" align="center" fixed="right">
          <template slot-scope="scope">
            <el-button icon="el-icon-success" type="primary" size="mini" @click="handlerOpenEdit(scope.row)" v-hasPermi="['admin:activity:enlist:check']">报名审核</el-button>
            <el-button icon="el-icon-success" type="success" size="mini" @click="handlerOpenCheck(scope.row)" v-if="scope.row.status === 1 && scope.row.filesArr.length > 0" v-hasPermi="['admin:activity:enlist:picture:check']">现场图片审核</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="listPram.page"
        :page-sizes="constants.page.limit"
        :layout="constants.page.layout"
        :total="listData.count"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-card>
    <!--审核-->
    <el-dialog
      :visible.sync="editDialogConfig.visible"
      title="报名信息审核"
      destroy-on-close
      :close-on-click-modal="false"
      width="700px"
    >
      <edit
        v-if="editDialogConfig.visible"
        :edit-data="editDialogConfig.editData"
        @hideEditDialog="hideEditDialog"
      />
    </el-dialog>
    <el-dialog
      :visible.sync="checkDialogConfig.visible"
      title="现场图片审核"
      destroy-on-close
      :close-on-click-modal="false"
      width="700px"
    >
      <check
        v-if="checkDialogConfig.visible"
        :edit-data="checkDialogConfig.editData"
        @hideCheckDialog="hideCheckDialog"
      />
    </el-dialog>
  </div>
</template>

<script>
import * as activityApi from '@/api/activity.js'
import * as roleApi from '@/api/role.js'
import { checkPermi } from "@/utils/permission";
import * as selfUtil from "@/utils/ZBKJIutil";
import * as categoryApi from "@/api/categoryApi";
import { getLightColor } from "@/utils";
import edit from './edit'
import check from './check'
export default {
  // name: "index"
  components: {edit,check },
  data() {
    return {
      constants:this.$constants,
      loading:false,
      listData: { list: [] },
      listPram: {
        keyword: '',
        activityId:null,
        /*departmentId: null,
        ipAddress: null,
        macAddress: null,
        personId: null,*/
        page: 1,
        limit: this.$constants.page.limit[0]
      },
      editDialogConfig: {
        visible: false,
        editData: {}
      },
      checkDialogConfig: {
        visible: false,
        editData: {}
      },

      activityList:{},
    }
  },
  mounted() {
    this.handleGetActivityEnlistList()

    this.handleGetActivityList() //用于下拉
  },
  methods: {
    checkPermi,
    handleGetActivityList() {
      const _pram = {
        page: 1,
        limit: 1000
      }
      activityApi.getList( _pram ).then(data => {
        this.activityList = data
      })
    },
    handleGetLightColor(status){
      return getLightColor(status)
    },

    handleSearch() {
      this.listPram.page = 1
      this.handleGetActivityEnlistList()
    },
    handleSizeChange(val) {
      this.listPram.limit = val
      this.handleGetActivityEnlistList()
    },
    handleCurrentChange(val) {
      this.listPram.page = val
      this.handleGetActivityEnlistList()
    },
    /*handlerOpenDel(rowData) {
      this.$confirm('确认删除当前数据').then(() => {
        const _pram = { id: rowData.id}
        activityApi.doDel(_pram).then(data => {
          this.$message.success('删除数据成功')
          this.handleGetActivityEnlistList()
        })
      })
    },*/

    handleGetActivityEnlistList() {
      activityApi.getEnlistList( this.listPram ).then(data => {
        this.listData.count = data.count
        this.listData.list = data.list
      })
    },
    handlerOpenEdit(editDate) {
      this.editDialogConfig.editData = editDate
      this.editDialogConfig.visible = true
    },
    hideEditDialog() {
      this.editDialogConfig.visible = false
      this.handleGetActivityEnlistList()
    },
    handlerOpenCheck(editDate) {
      this.checkDialogConfig.editData = editDate
      this.checkDialogConfig.visible = true
    },
    hideCheckDialog() {
      this.checkDialogConfig.visible = false
      this.handleGetActivityEnlistList()
    },
    resetQuery(){
      this.listPram.keyword = '';
      this.listPram.activityId = null;
      this.handleGetActivityEnlistList()
    }
  }
}
</script>

<style scoped>

</style>
